package com.evzgaga.evzrecon.plugins;

import com.evzgaga.evzrecon.annotations.CallbackHandler;
import com.evzgaga.evzrecon.dao.ScoreJpaController;
import com.evzgaga.evzrecon.domain.Score;
import com.evzgaga.evzrecon.event.ServerCallbackEvent;
import java.util.Map;

/**
 *
 * @author Bastien
 */
public class ScoresPlugin {

    @CallbackHandler(callbacks={"TrackMania.EndRace"})
    public void handleEndRace(ServerCallbackEvent event) {
        ScoreJpaController controller = new ScoreJpaController();
        Score score = new Score();
        Map<String, Object> challengeInfo = (Map<String, Object>) event.callbackParams.get(1);
        
//        Map<String, Object> playerRank = (Map<String, Object>) ((List)event.callbackParams.get(0)).get(0);
        
        score.setMapUid((String) challengeInfo.get("Uid"));
//        score.setRaceTime((Integer) playerRank.get("BestTime"));
        
        controller.create(score);
    }
}
